package weibo4j;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import weibo4j.http.ImageItem;
import weibo4j.http.Response;
import weibo4j.model.Emotion;
import weibo4j.model.Paging;
import weibo4j.model.PostParameter;
import weibo4j.model.Status;
import weibo4j.model.StatusWapper;
import weibo4j.model.WeiboException;
import weibo4j.org.json.JSONArray;
import weibo4j.org.json.JSONObject;
import weibo4j.util.WeiboConfig;


public class Timeline {

	/**
	 * @return list of statuses of the Public Timeline
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/public_timeline">statuses/public_timeline
	 *      </a>
	 * @since JDK 1.5
	 */
	public StatusWapper getPublicTimeline(Weibo weibo) throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(WeiboConfig
				.getValue("baseURL") + "statuses/public_timeline.json"));
	}

	/**
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/public_timeline">statuses/public_timeline
	 *      </a>
	 * @since JDK 1.5
	 */
	public StatusWapper getPublicTimeline(Weibo weibo, int count, int baseApp)
			throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/public_timeline.json", new PostParameter[] {
						new PostParameter("count", count),
						new PostParameter("base_app", baseApp) }));

	}

	/**
	 * 
	 * @return list of the Friends Timeline
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.1
	 * @see <a href="http://open.weibo.com/wiki/2/statuses/friends_timeline">
	 *      statuses/friends_timeline </a>
	 * @since JDK 1.5
	 */
	public StatusWapper getFriendsTimeline(Weibo weibo) throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(WeiboConfig
				.getValue("baseURL") + "statuses/friends_timeline.json"));

	}

	/**
	 * @see <a href="http://open.weibo.com/wiki/2/statuses/friends_timeline">
	 *      statuses/friends_timeline </a>
	 * @since JDK 1.5
	 */
	public StatusWapper getFriendsTimeline(Weibo weibo, Integer baseAPP, Integer feature,
			Paging paging) throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/friends_timeline.json",
				new PostParameter[] {
						new PostParameter("base_app", baseAPP.toString()),
						new PostParameter("feature", feature.toString()) },
				paging));
	}

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/friends_timeline/ids">
	 *      statuses/friends_timeline/ids </a>
	 * @since JDK 1.5
	 */
	public JSONObject getFriendsTimelineIds(Weibo weibo) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/friends_timeline/ids.json").asJSONObject();

	}

	public JSONObject getFriendsTimelineIds(Weibo weibo, Integer baseAPP, Integer feature,
			Paging paging) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/friends_timeline/ids.json",
				new PostParameter[] {
						new PostParameter("base_app", baseAPP.toString()),
						new PostParameter("feature", feature.toString()) },
				paging).asJSONObject();
	}

	/**
	 * @version weibo4j-V2 1.0.1
	 * @see <a href="http://open.weibo.com/wiki/2/statuses/home_timeline">
	 *      statuses/home_timeline </a>
	 * @since JDK 1.5
	 */
	public StatusWapper getHomeTimeline(Weibo weibo) throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(WeiboConfig
				.getValue("baseURL") + "statuses/home_timeline.json"));

	}

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.0
	 * @see <a href="http://open.weibo.com/wiki/2/Statuses/home_timeline">
	 *      statuses/home_timeline </a>
	 * @since JDK 1.5
	 */
	public StatusWapper getHomeTimeline(Weibo weibo, Integer baseAPP, Integer feature,
			Paging paging) throws WeiboException {
		return Status
				.constructWapperStatus(weibo.getClient().get(
						WeiboConfig.getValue("baseURL")
								+ "statuses/home_timeline.json",
						new PostParameter[] {
								new PostParameter("base_app", baseAPP
										.toString()),
								new PostParameter("feature", feature.toString()) },
						paging));
	}

	/**
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/user_timeline">statuses/user_timeline</a>
	 * @since JDK 1.5
	 */
	public StatusWapper getUserTimeline(Weibo weibo) throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(WeiboConfig
				.getValue("baseURL") + "statuses/user_timeline.json"));
	}

	public StatusWapper getUserTimelineByUid(Weibo weibo, String uid) throws WeiboException {
		return Status
				.constructWapperStatus(weibo.getClient().get(
						WeiboConfig.getValue("baseURL")
								+ "statuses/user_timeline.json",
						new PostParameter[] { new PostParameter("uid", uid) }));
	}

	public StatusWapper getUserTimelineByName(Weibo weibo, String screen_name)
			throws WeiboException {
		return Status
				.constructWapperStatus(weibo.getClient().get(
						WeiboConfig.getValue("baseURL")
								+ "statuses/user_timeline.json",
						new PostParameter[] { new PostParameter("screen_name",
								screen_name) }));
	}

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/user_timeline">statuses/user_timeline</a>
	 * @since JDK 1.5
	 */
	public StatusWapper getUserTimelineByUid(Weibo weibo, String uid, Paging page,
			Integer base_app, Integer feature) throws WeiboException {
		return Status
				.constructWapperStatus(weibo.getClient().get(
						WeiboConfig.getValue("baseURL")
								+ "statuses/user_timeline.json",
						new PostParameter[] {
								new PostParameter("uid", uid),
								new PostParameter("base_app", base_app
										.toString()),
								new PostParameter("feature", feature.toString()) },
						page));
	}

	public StatusWapper getUserTimelineByName(Weibo weibo, String screen_name, Paging page,
			Integer base_app, Integer feature) throws WeiboException {
		return Status
				.constructWapperStatus(weibo.getClient().get(
						WeiboConfig.getValue("baseURL")
								+ "statuses/user_timeline.json",
						new PostParameter[] {
								new PostParameter("screen_name", screen_name),
								new PostParameter("base_app", base_app
										.toString()),
								new PostParameter("feature", feature.toString()) },
						page));
	}

	/**
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/user_timeline">statuses/user_timeline</a>
	 * @since JDK 1.5
	 */
	public JSONObject getUserTimelineIdsByUid(Weibo weibo, String uid) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/user_timeline/ids.json",
				new PostParameter[] { new PostParameter("uid", uid) })
				.asJSONObject();
	}

	public JSONObject getUserTimelineIdsByName(Weibo weibo, String screen_name)
			throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/user_timeline/ids.json",
				new PostParameter[] { new PostParameter("screen_name",
						screen_name) }).asJSONObject();
	}

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/repost_timeline">statuses/repost_timeline</a>
	 * @since JDK 1.5
	 */
	public StatusWapper getRepostTimeline(Weibo weibo, String id) throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/repost_timeline.json",
				new PostParameter[] { new PostParameter("id", id) }));
	}

	/**
	 * @return list of Status
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/repost_timeline">statuses/repost_timeline</a>
	 * @since JDK 1.5
	 */
	public StatusWapper getRepostTimeline(Weibo weibo, String id, Paging page)
			throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/repost_timeline.json",
				new PostParameter[] { new PostParameter("id", id) }, page));
	}

	/**
	 * href="http://open.weibo.com/wiki/2/statuses/repost_timeline/ids">statuses
	 * /repost_timeline/ids</a>
	 * 
	 * @since JDK 1.5
	 */
	public JSONObject getRepostTimelineIds(Weibo weibo, String id) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/repost_timeline/ids.json",
				new PostParameter[] { new PostParameter("id", id) })
				.asJSONObject();
	}

	/**
	 * 
	 * @return list of Status
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/repost_by_me">statuses/repost_by_me</a>
	 * @since JDK 1.5
	 */
	public StatusWapper getRepostByMe(Weibo weibo) throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(WeiboConfig
				.getValue("baseURL") + "statuses/repost_by_me.json"));
	}

	/**
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/repost_by_me">statuses/repost_by_me</a>
	 * @since JDK 1.5
	 */
	public StatusWapper getRepostByMe(Weibo weibo, Paging page) throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "statuses/repost_by_me.json",
				null, page));
	}

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/mentions">statuses/mentions</a>
	 * @since JDK 1.5
	 */
	public StatusWapper getMentions(Weibo weibo) throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(WeiboConfig
				.getValue("baseURL") + "statuses/mentions.json"));
	}

	/**
	 * @return list of Status
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/mentions">statuses/mentions</a>
	 * @since JDK 1.5
	 */
	public StatusWapper getMentions(Weibo weibo, Paging page, Integer filter_by_author,
			Integer filter_by_source, Integer filter_by_type)
			throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "statuses/mentions.json",
				new PostParameter[] {
						new PostParameter("filter_by_author", filter_by_author
								.toString()),
						new PostParameter("filter_by_source", filter_by_source
								.toString()),
						new PostParameter("filter_by_type", filter_by_type
								.toString()) }, page));
	}

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/mentions/ids">statuses/mentions/ids</a>
	 * @since JDK 1.5
	 */
	public JSONObject getMentionsIds(Weibo weibo) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "statuses/mentions/ids.json")
				.asJSONObject();
	}

	public JSONObject getMentionsIds(Weibo weibo, Paging page, Integer filter_by_author,
			Integer filter_by_source, Integer filter_by_type)
			throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "statuses/mentions/ids.json",
				new PostParameter[] {
						new PostParameter("filter_by_author", filter_by_author
								.toString()),
						new PostParameter("filter_by_source", filter_by_source
								.toString()),
						new PostParameter("filter_by_type", filter_by_type
								.toString()) }, page).asJSONObject();
	}

	/**
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/bilateral_timeline">statuses/bilateral_timeline</a>
	 * @since JDK 1.5
	 */
	public StatusWapper getBilateralTimeline(Weibo weibo) throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(WeiboConfig
				.getValue("baseURL") + "statuses/bilateral_timeline.json"));
	}

	public StatusWapper getBilateralTimeline(Weibo weibo, Integer base_app, Integer feature)
			throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/bilateral_timeline.json",
				new PostParameter[] { new PostParameter("base_app", base_app),
						new PostParameter("feature", feature) }));
	}

	/**
	 * @return Status
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/show">statuses/show</a>
	 * @since JDK 1.5
	 */
	public Status showStatus(Weibo weibo, String id) throws WeiboException {
		return new Status(weibo.getClient().get(WeiboConfig.getValue("baseURL")
				+ "statuses/show.json",
				new PostParameter[] { new PostParameter("id", id) }));
	}

	/**
	 * d * @throws WeiboException when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/querymid">statuses/querymid</a>
	 * @since JDK 1.5
	 */
	public JSONObject QueryMid(Weibo weibo, Integer type, String id) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "statuses/querymid.json",
				new PostParameter[] { new PostParameter("id", id),
						new PostParameter("type", type.toString()) })
				.asJSONObject();
	}

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/querymid">statuses/querymid</a>
	 * @since JDK 1.5
	 */
	public JSONObject QueryMid(Weibo weibo, Integer type, String id, int is_batch)
			throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "statuses/querymid.json",
				new PostParameter[] { new PostParameter("id", id),
						new PostParameter("type", type.toString()),
						new PostParameter("is_batch", is_batch) })
				.asJSONObject();
	}

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/queryid">statuses/queryid</a>
	 * @since JDK 1.5
	 */
	public JSONObject QueryId(Weibo weibo, String mid, Integer type, int isBase62)
			throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "statuses/queryid.json",
				new PostParameter[] { new PostParameter("mid", mid),
						new PostParameter("type", type.toString()),
						new PostParameter("isBase62", isBase62) })
				.asJSONObject();
	}

	/**
	 * @return Status's id
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/queryid">statuses/queryid</a>
	 * @since JDK 1.5
	 */
	public JSONObject QueryId(Weibo weibo, String mid, Integer type, Integer isBatch,
			Integer isBase62) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "statuses/queryid.json",
				new PostParameter[] { new PostParameter("mid", mid),
						new PostParameter("type", type.toString()),
						new PostParameter("is_batch", isBatch.toString()),
						new PostParameter("isBase62", isBase62.toString()) })
				.asJSONObject();
	}

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/hot/repost_daily">statuses/hot/repost_daily</a>
	 * @since JDK 1.5
	 */
	public JSONArray getRepostDaily(Weibo weibo) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/hot/repost_daily.json").asJSONArray();
	}

	/**
	 * @return Status
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/hot/repost_daily">statuses/hot/repost_daily</a>
	 * @since JDK 1.5
	 */
	public JSONArray getRepostWeekly(Weibo weibo) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/hot/repost_weekly.json").asJSONArray();
	}

	/**
	 * 
	 * @return Status
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/hot/repost_daily">statuses/hot/repost_daily</a>
	 * @since JDK 1.5
	 */
	public JSONArray getCommentsDaily(Weibo weibo) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/hot/comments_daily.json").asJSONArray();
	}

	/**
	 * 
	 * @return Status
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/hot/repost_daily">statuses/hot/repost_daily</a>
	 * @since JDK 1.5
	 */
	public JSONArray getCommentsWeekly(Weibo weibo) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "statuses/hot/comments_weekly.json").asJSONArray();
	}

	/**
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/repost">statuses/repost</a>
	 * @since JDK 1.5
	 */
	public Status Repost(Weibo weibo, String id) throws WeiboException {
		return new Status(weibo.getClient().post(WeiboConfig.getValue("baseURL")
				+ "statuses/repost.json",
				new PostParameter[] { new PostParameter("id", id) }));
	}

	/**
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/repost">statuses/repost</a>
	 * @since JDK 1.5
	 */
//<<<<<<< .mine
//	public synchronized Status Repost(String id, String status, Integer is_comment,
//				String token)
//=======
	public Status Repost(Weibo weibo, String id, String status, Integer is_comment)
			throws WeiboException {
		return new Status(weibo.getClient().post(WeiboConfig.getValue("baseURL")
				+ "statuses/repost.json", new PostParameter[] {
				new PostParameter("id", id),
				new PostParameter("status", status),
				new PostParameter("is_comment", is_comment.toString()) }));
	}

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/destroy">statuses/destroy</a>
	 * @since JDK 1.5
	 */
	public Status Destroy(Weibo weibo, String id) throws WeiboException {
		return new Status(weibo.getClient().post(WeiboConfig.getValue("baseURL")
				+ "statuses/destroy.json",
				new PostParameter[] { new PostParameter("id", id) }));
	}

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/update">statuses/update</a>
	 * @since JDK 1.5
	 */
	public Status UpdateStatus(Weibo weibo, String status) throws WeiboException {
		return new Status(weibo.getClient().post(WeiboConfig.getValue("baseURL")
				+ "statuses/update.json",
				new PostParameter[] { new PostParameter("status", status) }));
	}

	/**
	 * @return Status
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/update">statuses/update</a>
	 * @since JDK 1.5
	 */
	public Status UpdateStatus(Weibo weibo, String status, Float lat, Float longs,
			String annotations) throws WeiboException {
		return new Status(weibo.getClient().post(WeiboConfig.getValue("baseURL")
				+ "statuses/update.json", new PostParameter[] {
				new PostParameter("status", status),
				new PostParameter("lat", lat.toString()),
				new PostParameter("long", longs.toString()),
				new PostParameter("annotations", annotations) }));
	}

	/**
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/upload">statuses/upload</a>
	 * @since JDK 1.5
	 */
	public Status UploadStatus(Weibo weibo, String status, ImageItem item)
			throws WeiboException {
		return new Status(weibo.getClient().multPartURL(
				WeiboConfig.getValue("baseURL") + "statuses/upload.json",
				new PostParameter[] { new PostParameter("status", status) },
				item));
	}
	
	/**
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="https://api.weibo.com/2/statuses/upload_url_text.json">statuses/upload</a>
	 * @since JDK 1.5
	 */
	public Status UploadStatus(Weibo weibo, String status, String imgUrl)
			throws WeiboException {
		return new Status(weibo.getClient().post(WeiboConfig.getValue("baseURL") + "statuses/upload_url_text.json", new PostParameter[]{
			new PostParameter("status", status),
			new PostParameter("url", imgUrl)
		}));
//		return new Status(weibo.getClient().multPartURL(
//				WeiboConfig.getValue("baseURL") + "statuses/upload_url_text.json",
//				new PostParameter[] { new PostParameter("status", status) },
//				item));
	}
	

	/**
	 * when Weibo service or network is unavailable
	 * 
	 * @version weibo4j-V2 1.0.0
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/statuses/upload">statuses/upload</a>
	 * @since JDK 1.5
	 */
	public Status UploadStatus(Weibo weibo, String status, ImageItem item, Float lat,
			Float longs) throws WeiboException {
		return new Status(weibo.getClient().multPartURL(
				WeiboConfig.getValue("baseURL") + "statuses/upload.json",
				new PostParameter[] { new PostParameter("status", status),
						new PostParameter("lat", lat.toString()),
						new PostParameter("long", longs.toString()) }, item));
	}

	/**
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.0
	 * @see <a href="http://open.weibo.com/wiki/2/emotions">emotions</a>
	 * @since JDK 1.5
	 */
	public List<Emotion> getEmotions(Weibo weibo) throws WeiboException {
		return Emotion.constructEmotions(weibo.getClient().get(WeiboConfig
				.getValue("baseURL") + "emotions.json"));
	}

	/**
	 * @see <a href="http://open.weibo.com/wiki/2/emotions">emotions</a>
	 * @since JDK 1.5
	 */
	public List<Emotion> getEmotions(Weibo weibo, String type, String language)
			throws WeiboException {
		return Emotion.constructEmotions(weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "emotions.json",
				new PostParameter[] { new PostParameter("type", type),
						new PostParameter("language", language) }));
	}
	
	public static void main(String args[]) {
		try {
			byte[] content = readFileImage("test.jpg");
			String str = "达尔文交响乐团将于2013年10月18日和19日移师澳大利亚中部大岩石乌鲁鲁，在世界上最美的日落里奏响难忘的华美篇章。对于交响乐爱好者，以及想以另一种方式探秘澳大利亚中心乌鲁鲁的人来说，是一次绝对不能错过的机会。以神秘古老的乌鲁鲁为背景http://192.168.1.102:8080/cubetravel/views/news/news.do?action=showNewsDetail&newsId=7";
			System.out.println("content length:" + content.length);
			ImageItem pic = new ImageItem("pic", content);
			String s = java.net.URLEncoder.encode(str, "utf-8");
			Timeline tl = new Timeline();
			Weibo weibo = new Weibo();
			weibo.setToken("2.00Ch47sB_hK8cDe673e06b7a0laLaN");// access_token
			
			Response resp = weibo.getClient().multPartURL("https://api.weibo.com/2/statuses/upload.json", new PostParameter[]{
					new PostParameter("status", s),
					//new PostParameter("url", "http://www.zentravel.cn/upload/images/hotel/57/vUFVv2.jpg"),
			},pic);
//			Status status = tl.UploadStatus(weibo, s, pic);
//			Status status = tl.UploadStatus(s, pic);

			Status status = new Status(resp);
			System.out.println("Successfully upload the status to ["
					+ status.getText() + "].");
		} catch (Exception e1) {
			e1.printStackTrace();
		}
	}

	public static byte[] readFileImage(String filename) throws IOException {
		InputStream is = Timeline.class.getClassLoader().getResourceAsStream(filename);
		BufferedInputStream bufferedInputStream = new BufferedInputStream(
				is);
		int len = bufferedInputStream.available();
		byte[] bytes = new byte[len];
		int r = bufferedInputStream.read(bytes);
		if (len != r) {
			bytes = null;
			throw new IOException("读取文件不正确");
		}
		bufferedInputStream.close();
		return bytes;
	}
}
